package ch08.d1;

import org.junit.Test;

import java.util.Scanner;

public class ExceptionTest {
    @Test

    public void testNumber(){

        System.out.println("start");
        Scanner scan=new Scanner(System.in);


        try {
            int n = scan.nextInt();
            int x = 10 / n;//取餐
            System.out.println("结果：" + x);

            String[] a={"a","b","c"};
            n=scan.nextInt();

            System.out.println(a[n]);

        }catch (ArithmeticException e) {
            System.out.println("除数不能为0");
            e.printStackTrace();//打印异常信息
        }catch (ArrayIndexOutOfBoundsException e){
            System.out.println("数组越界");
        }catch (Exception e){
            System.out.println("出错了");
        }finally{
            //关闭资源、数据库连接，保持数据
            System.out.println("finally 最终要执行的代码");
        }




        System.out.println("end");


    }
    void m1(int x){

    }
}
